<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	积分、余额日志
*/
defined('BY_JYA') or exit('error');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'duilist';
$return=array();
if($_RQ['op']=='duilist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>0);
	$return['params']=array();
	//会员ID
	if(!empty($_RQ['type'])){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=$_RQ['type'];
	}
	//时间范围
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['createtime']=$time_range;
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
	}
	$list=pdo_getslice('jy_dayfee_zlog',$params,array($pindex,$psize),$total,array(),'','id desc');
	if($list){
		foreach($list as $k=>&$item){
			$item['member']=cfc('core')->member_show($item['mid']);
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'duilist','title'=>'兑换记录'),
		),
		'list'=>array('data'=>'list','tip'=>'','edit'=>false,'list'=>array(
			array('name'=>'member','title'=>'会员信息_Member','type'=>'member'),
			array('name'=>'afee','title'=>'消耗广告值','type'=>'string'),
			array('name'=>'zprice','title'=>'通行证价格','type'=>'string'),
			array('name'=>'znum','title'=>'获得通行证数量','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search'=>array(
			array('type'=>'time_range','width'=>18,'title'=>'创建时间','name'=>'createtime','help'=>''),
		),
	);
	exi($return);
}
if($_RQ['op']=='tilist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>1);
	$return['params']=array();
	//会员ID
	if(!empty($_RQ['type'])){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=$_RQ['type'];
	}
	//时间范围
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['createtime']=$time_range;
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
	}
	$list=pdo_getslice('jy_dayfee_zlog',$params,array($pindex,$psize),$total,array(),'','id desc');
	if($list){
		foreach($list as $k=>&$item){
			$item['member']=cfc('core')->member_show($item['mid']);
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'tilist','title'=>'提现记录'),
		),
		'list'=>array('data'=>'list','tip'=>'','edit'=>false,'list'=>array(
			array('name'=>'member','title'=>'会员信息_Member','type'=>'member'),
			array('name'=>'ztitle','title'=>'通证账户名','type'=>'string'),
			array('name'=>'zname','title'=>'通证账号','type'=>'string'),
			array('name'=>'znum','title'=>'消耗通证数量','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		),'action'=>array(
			array('op'=>'check','title'=>'审核','type'=>'modal','show'=>array('status'=>0)),
		)),
		'search'=>array(
			array('type'=>'time_range','width'=>18,'title'=>'创建时间','name'=>'createtime','help'=>''),
		),
	);
	exi($return);
}
if($_RQ['op']=='zhuanlist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>2);
	$return['params']=array();
	//会员ID
	if(!empty($_RQ['type'])){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=$_RQ['type'];
	}
	//时间范围
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['createtime']=$time_range;
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
	}
	$list=pdo_getslice('jy_dayfee_zlog',$params,array($pindex,$psize),$total,array(),'','id desc');
	if($list){
		foreach($list as $k=>&$item){
			$item['member']=cfc('core')->member_show($item['mid']);
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'zhuanlist','title'=>'互转记录'),
		),
		'list'=>array('data'=>'list','tip'=>'','edit'=>false,'list'=>array(
			array('name'=>'member','title'=>'会员信息_Member','type'=>'member'),
			array('name'=>'tomember','title'=>'转与对象','type'=>'member'),
			array('name'=>'znum','title'=>'转通行证数量','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search'=>array(
			array('type'=>'time_range','width'=>18,'title'=>'创建时间','name'=>'createtime','help'=>''),
		),
	);
	exi($return);
}
if($_RQ['op']=='check'){
	//设置默认佣金比例
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		pdo_update('jy_dayfee_zlog',array('status'=>$post['status']),array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));;
		exi('操作成功！','','list');
	}
	$id=$_RQ['id'];
	$item=pdo_get('jy_dayfee_zlog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));;
	if(!$item){
		exi('请选择记录！','error');
	}
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'desc'=>'提现审核',
		'edit'=>array(
			array('name'=>'ztitle','title'=>'通证账户名','type'=>'copy'),
			array('name'=>'zname','title'=>'通证账号','type'=>'copy'),
			array('name'=>'znum','title'=>'提现通证数量','type'=>'copy'),
			array('type'=>'radio','title1'=>'审核','name'=>'status','options'=>'status'),
		),
	);
	$return['status']=array('待审核','审核通过','审核不通过');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op'] == 'del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_dayfee_zlog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_dayfee_zlog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
			}
		}
	}
	exi('删除成功！');
}